package cn.geodata.dataview.util;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.ArrayList;

import javax.xml.transform.TransformerException;

import org.geotools.factory.FactoryRegistryException;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.IllegalAttributeException;
import org.geotools.feature.SchemaException;
import org.geotools.gml.producer.FeatureTransformer;
import org.junit.Test;
import org.xml.sax.SAXException;

public class UtilTest {


	public void atestLocatePathRow() throws IOException, SAXException, FactoryRegistryException, IllegalAttributeException, SchemaException, URISyntaxException, TransformerException {
		ArrayList<int[]> _pathrow = new ArrayList<int[]>();
		_pathrow.add(new int[]{23, 33});
		
		FeatureCollection _fs = Util.locatePathRows(_pathrow);
		
		ByteArrayOutputStream _stream = new ByteArrayOutputStream();

		FeatureTransformer _transformer = new FeatureTransformer();
		_transformer.setIndentation(4);
		_transformer.getFeatureNamespaces().declarePrefix("PathRow", "http://www.geodata.cn/dataview");
		_transformer.transform(_fs, _stream);
		
		System.out.println(_stream.toString());
//		FeatureIterator _it = _fs.features();
//		Feature _f = null;
//		while(_it.hasNext()){
//			_f = _it.next();
//			System.out.println("aaa");
//		}
//		_it.close();
//		
//		assertNotNull(_fs);
//		
//		GMLConfiguration _configure = new GMLConfiguration();
//		Encoder _encoder = new Encoder(_configure);
//		
//		
//		assertNotNull(GML.FeatureCollection);
//		_encoder.encode(_fs, GML.FeatureCollection, _stream);
//		
//		System.out.println(_stream.toString());
	}
	
	@Test
	public void testTest1() throws Exception {
//		PropertiesConfiguration _props = new PropertiesConfiguration(UtilTest.class.getResource("/conf/Repository.txt"));
//		for(String _path : _props.getStringArray("path")){
//			System.out.println(_path);
//		}
//		_props.addProperty("path", "eeeee");
//		_props.save();
	}
}
